package com.mendmix.tutorial.endpoint;

import com.mendmix.tutorial.api.gaussdbuserd.ActorApi;
import com.mendmix.tutorial.domain.Actor;
import com.mendmix.tutorial.service.IActorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class ActorEndpoint implements ActorApi {
    @Autowired
    private IActorService actorService;

    @Override
    public List<Object> listActors() {
        List<Actor> actors = actorService.listActors();
        return new ArrayList<>(actors);
    }

    @Override
    public Actor getActor(Integer actorId) {
        return actorService.getActor(actorId);
    }

    @Override
    public boolean deleteActor(Integer actorId) {
        return actorService.deleteActor(actorId);
    }

    @Override
    public Actor addActor(String firstName, String lastName) {
        return actorService.addActor(firstName, lastName);
    }
}
